from django.contrib import admin
from django.urls import path,include
from .views import StudentViewSet,ClassesViewSet
from rest_framework.routers import DefaultRouter
urlpatterns = [
    # 127.0.0.1:8000/drfstudy/students  ==》get  ==>StudentViewSet==>list方法
    # path("students/",StudentViewSet.as_view({"get":"list","post":"create"})),
    # # 127.0.0.1:8000/drfstudy/students/1/ ==》get  ==>StudentViewSet==>retrieve方法
    # path("students/<pk>/",StudentViewSet.as_view({"get":"retrieve","put":"update","delete":"destroy"})),
]

router = DefaultRouter() # 实例化 得到路由器对象
# 注册路由
router.register("students",StudentViewSet)
router.register("classes",ClassesViewSet)
# 拼接路由
urlpatterns += router.urls